#include <stdio.h>
#include <malloc.h>

#define MaxSize 50
typedef char ElemType;
typedef struct{
	ElemType data[MaxSize];
	int length;
}SqList;
/*void CreateList(SqList * &L,ElemType a[],int n){
	int i=0,k=0;
	L=(SqList *)malloc(sizeof(Sqlist));
	while(i<n){
		L->data[i]=a[i];
		k++;i++;
	}
	L->length=k;
}*/
void InitList(SqList *&L){
	L=(SqList *)malloc(sizeof(SqList));
	L->length=0;
}
void DestroyList(SqList *&L){
	free(L);
}
void DispList(SqList *&L){
	int i=0;
	for(i=0;i<L->length;i++){
		printf("%d ",L->data[i]);
	}
	printf("\n");
}
bool ListInsert(SqList *&L,int i,ElemType e){
	int j;
	if(i<L->length||i>L->length+1)
	return false;
	i--;
	for(j=L->length;j>i;j--)
		L->data[j]=L->data[j-1];
	L->data[i]=e;
	L->length++;
	return true;	
	
}
int ListEmpty(SqList *L){
	if(L->length==0)
	return 1;
	return 0;
}
bool ListDelete(SqList *L,int i){
	int j;
	if(i<1||i>L->length+1)
	return false;
	i--;
	for(j=L->length;i<j;i++)
	L->data[i]=L->data[i+1];
	L->length--;
	return true;
	
}
int main(){
	SqList *L;
	ElemType e;
	InitList(L);
	ListInsert(L,1,1);
	ListInsert(L,2,3);
	ListInsert(L,3,5);
	ListDelete(L,2);
	DispList(L);
}
